package com.vehicle.controller;

import com.vehicle.bean.DataGridView;
import com.vehicle.bean.PageVo;
import com.vehicle.pojo.OutwardRecord;
import com.vehicle.service.OutwardRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
@RequestMapping("outWardRecord")
public class OutwardRecordController {

    @Autowired
    private OutwardRecordService outwardRecordService;

    @RequestMapping("findAllOutWardRecord")
    @ResponseBody
    public DataGridView findAllOutWardRecord(String startDate, String endDate, PageVo pageVo){
        DataGridView allOutwardRecord = outwardRecordService.findAllOutwardRecord(startDate, endDate, pageVo);
        return allOutwardRecord;
    }

    @RequestMapping("delOutward")
    @ResponseBody
    public DataGridView deloutWard(Integer outwardid){
        DataGridView dataGridView = outwardRecordService.deleteOutward(outwardid);
        return dataGridView;
    }

    @RequestMapping("outWardRecordCheck")
    public ModelAndView outWardRecordCheck(Integer outwardid){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("/page/car/OutwardRecordCheck.jsp");
        OutwardRecord outwardRecord = outwardRecordService.findOutwardRecordById(outwardid);
        modelAndView.addObject("outwardRecord",outwardRecord);
        return modelAndView;
    }

}
